//
//  BySuperHandleViews.m
//  caipiao_ios
//
//  Created by mc on 2018/7/12.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "BySuperHandleViews.h"

@implementation BySuperHandleViews

- (id)init{
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
       
        
        UIButton *sureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:sureBtn];
        [sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(0);
            make.bottom.equalTo(self).offset(0);
            make.top.equalTo(self).offset(0);
            make.width.mas_equalTo(@150);
        }];
        sureBtn.backgroundColor = BY_THEME_COLOR;
        [sureBtn setTitle:@"确定" forState:UIControlStateNormal];
        [sureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        sureBtn.titleLabel.font = FONT(14);
        sureBtn.tag = 100;
        
       
        
        UIButton *pauseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:pauseBtn];
        [pauseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(10);
            make.centerY.equalTo(self).offset(0);
            make.size.mas_equalTo(CGSizeMake(40, 25));
        }];
        
        pauseBtn.tag = 102;
        [pauseBtn setTitle:@"机选" forState:UIControlStateNormal];
        [pauseBtn setTitleColor:BY_THEME_COLOR forState:UIControlStateNormal];
        pauseBtn.titleLabel.font = FONT(12);
        pauseBtn.layer.cornerRadius = 3;
        pauseBtn.layer.borderColor = BY_THEME_COLOR.CGColor;
        pauseBtn.layer.borderWidth = 1;
        
        
        UIButton *clearBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:clearBtn];
        [clearBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self).offset(0);
            make.left.equalTo(pauseBtn.mas_right).offset(10);
            make.size.mas_equalTo(CGSizeMake(60, 20));
        }];
        [clearBtn setTitle:@"清除已选" forState:UIControlStateNormal];
        [clearBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        clearBtn.titleLabel.font = FONT(12);
        clearBtn.tag = 101;
        
        
    
        UILabel *countLabel = [[UILabel alloc] init];
        [self addSubview:countLabel];
        [countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(clearBtn.mas_right).offset(10);
            make.right.equalTo(sureBtn.mas_left).offset(-10);
            make.bottom.equalTo(sureBtn.mas_bottom).offset(-5);
            make.height.mas_equalTo(@15);
        }];
        countLabel.text = @"0注";
        countLabel.textColor = BY_TEXT_COLOR;
        countLabel.textAlignment = NSTextAlignmentRight;
        countLabel.font = FONT(14);
        self.countLabel = countLabel;
        
        
        UILabel *valueLabel = [[UILabel alloc] init];
        [self addSubview:valueLabel];
        [valueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(countLabel.mas_left).offset(0);
            make.right.equalTo(countLabel.mas_right).offset(0);
            make.top.equalTo(sureBtn.mas_top).offset(5);
            make.height.mas_equalTo(@15);
        }];
        valueLabel.text = @"0元";
        valueLabel.textColor = BY_THEME_COLOR;
        valueLabel.textAlignment = NSTextAlignmentRight;
        valueLabel.font = FONT(14);
        self.valueLabel = valueLabel;
        
        [sureBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        [clearBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        [pauseBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}


- (void)btnAction:(UIButton *)btn{
    if (btn.tag == 100) {
        self.sureBlock();
        
    }else if (btn.tag == 101){
        
        self.clearBlock();
        
    }else if (btn.tag == 102){
        
        self.pauseBlock();
        
    }
}


@end
